/**
 * Created by 10520_000 on 10/23/14.
 */

$(document).ready(function () {
//    ISS.EVENT.bindEvent('#submit_button', 'click', function(){
//        sendInfo();
////        submit();
//    })

    var ob = $("#multipleupload").uploadFile({
        url: contextPath + "/service/indexTest/test",
        autoSubmit:false,
        multiple:true,
        fileName:"myfile",
        formData: {"maCTSP": "CTSP001"}
    });
    ISS.EVENT.bindEvent('#startUpload', 'click', function () {
        ob.startUpload();
    });

    ISS.EVENT.bindEvent('#demo2', 'click', function () {
        block_screen('#test_lock');
    });
});

function sendInfo() {
    var user = {};
    user.id = '';
    user.lastName = ISS.DOM.getVal('#first_name');
    user.firstName = ISS.DOM.getVal('#last_name');
    user.address = ISS.DOM.getVal('#address');

    ISS.BACKEND.request({
        url: 'service/indexTest/test',
        headers: {
            'Accept': 'application/json',
            'Content-Type': 'application/json'
        },
        type: 'POST',
        dataType: 'json',
        data: JSON.stringify(user),
        success: function (data) {
            var responseContent = data.responseObject;
            var user = new ISS.DOMAIN.User(responseContent);
            alert(user.firstName);
        }
    });
}

function block_screen() {
    $('<div id="screenBlock"></div>').appendTo('body');
    $('#screenBlock').css( { opacity: 0, width: $(document).width(), height: $(document).height() } );
    $('#screenBlock').addClass('blockDiv');
    $('#screenBlock').animate({opacity: 0.7}, 200);
}

function unblock_screen() {
    $('#screenBlock').animate({opacity: 0}, 200, function() {
        $('#screenBlock').remove();
    });
}

function submit() {
    ISS.BACKEND.downloadFile('service/indexTest/test', '#from_test');
}
